/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package poker.neuralnetwork;

import java.util.ArrayList;
import poker.neuralnetwork.functions.Function;
import java.util.List;

/**
 * Abstract class for making perceptrons. The assumed difference between
 * different perceptrons is their function. For example, there are
 * linear, sigmoid, discontinuous (0 or 1), and input perceptrons (which don't
 * have functions.
 *
 * Also useful for other genres of "perceptron", such as a threshold value,
 * which just is a perceptron which always outputs a 1. Other dummy types may
 * be useful as well.
 *
 *
 * Note: AbstractPerceptron classes should be immutable!
 *
 *
 * @param <T> 
 * @author Benjamin L. Brodie <blbrodie@gmail.com>
 */
public abstract class AbstractPerceptron implements Perceptron {
    private List<Edge> edges; //list of the edges
    private Function function;   // private Function function;

    public AbstractPerceptron(List<Edge> edges, Function function){
        this.edges = edges;
        this.function = function;
    }





    /**
     *
     * @return the output of the perceptron
     */
    public double output(){
        return function.f(inputSum());
    }

    public List<Edge> getEdges(){
        return new ArrayList<Edge>(edges);
    }

    //returns the weighted sum of the inputs
    private double inputSum(){
        double sum = 0;

        for (Edge e : edges){
            sum += e.input();
        }

        return sum;
    }

    @Override
    public String toString(){
        return this.getClass().getName();


    }





}
